home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / gate / Gate_ByDesc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-05  |  1.8 KB  |  67 lines

  1. /* 
  2.  * Gate_ByDesc.c --
  3.  *
  4.  *    Source code for the Gate_ByDesc library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/gate/RCS/Gate_ByDesc.c,v 1.1 92/06/04 22:03:19 jhh Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <stdio.h>
  21. #include <gate.h>
  22. #include <gateInt.h>
  23. #include <string.h>
  24.  
  25.  
  26. /*
  27.  *-----------------------------------------------------------------------
  28.  *
  29.  * Gate_ByDesc --
  30.  *
  31.  *    Return information about a gateway based on its description.
  32.  *
  33.  * Results:
  34.  *    A Gate_Entry pointer describing the gateway, or NULL if no such gateway
  35.  *    exists in the current database.  The Gate_Entry is statically
  36.  *    allocated, and may be modified on the next call to any Gate_
  37.  *    procedure.
  38.  *
  39.  * Side Effects:
  40.  *    The gateway file is opened if it wasn't already.
  41.  *
  42.  *-----------------------------------------------------------------------
  43.  */
  44.  
  45. Gate_Entry *
  46. Gate_ByDesc(desc)
  47.     register char     *desc;      /* Name of gateway to find */
  48. {
  49.     register Gate_Entry    *entry;        /* Current entry */
  50.     register char     **cpp;        /* Pointer to alias table */
  51.  
  52.     if (Gate_Start() != 0) {
  53.     return ((Gate_Entry *)NULL);
  54.     }
  55.     
  56.     while (1) {
  57.     entry = Gate_Next();
  58.     if (entry != (Gate_Entry *)NULL) {
  59.         if (strcmp(entry->desc, desc) == 0) {
  60.         return (entry);
  61.         }
  62.     } else {
  63.         return (Gate_Entry *) NULL;
  64.     }
  65.     }
  66. }
  67.